create or replace view vac_page_regions as
with pr as
(
 select
 workspace,
 application_id,
 application_name,
 page_id,
 region_id,
 page_name,
 region_name,
 parent_region_id,
 parent_region_name,
 template,
 template_id,
 static_id, rest_enabled,
 to_char(display_sequence) display_sequence,
 display_region_selector,
 region_attributes_substitution,
 to_char(display_column) display_column,
 display_position,
 display_position_code,
--
 ac_utils.hs(region_source) region_source_hs,
 dbms_lob.substr(region_source,4000, 1)        region_source_sr1,
 dbms_lob.substr(region_source,4000, 4000+1 )  region_source_sr2,
 dbms_lob.substr(region_source,4000, 8000+1 )  region_source_sr3,
 dbms_lob.substr(region_source,4000, 12000+1)  region_source_sr4,
--
 breadcrumb_template,
 breadcrumb_template_id,
 list_template_override,
 list_template_override_id,
 source_type,
 source_type_code,
 on_error_message,
 authorization_scheme,
 authorization_scheme_id,
 condition_type,
 condition_expression1,
 condition_expression2,
 region_header_text,
 region_footer_text,
 report_template,
 report_template_id,
 report_column_headings,
 headings_type,
 to_char(maximum_rows_to_query) maximum_rows_to_query,
 pagination_scheme,
 pagination_display_position,
 ajax_enabled,
 number_of_rows_item,
 no_data_found_message,
 more_data_found_message,
 to_char(maximum_row_count) maximum_row_count,
 report_null_values_as,
 breaks,
 ascending_image,
 ascending_image_attributes,
 descending_image,
 descending_image_attributes,
 filename,
 separator,
 enclosed_by,
 strip_html,
 report_column_source_type,
 to_char(max_dynamic_report_cols) max_dynamic_report_cols,
 html_table_cell_attributes,
 customization,
 customization_name,
 build_option,
 to_char(build_option_id) build_option_id,
 region_caching,
 to_char(timeout_cache_after) timeout_cache_after,
 cache_when,
 cache_when_expression_1,
 cache_when_expression_2,
 sum_display_text,
 break_display_text,
 before_break_display_text,
 break_column_display_text,
 after_break_display_text,
 break_display_flag,
 repeat_heading_break_format,
 enable_csv_output,
 csv_link_label,
 url,
 link_label,
 translate_region_title,
 attribute_01,
 attribute_02,
 attribute_03,
 attribute_04,
 attribute_05,
 attribute_06,
 attribute_07,
 attribute_08,
 attribute_09,
 attribute_10,
 component_comment,
 'APEX_APPLICATION_PAGE_REGIONS' src_view_name
 from apex_application_page_regions
)
select workspace,
       application_id,
       application_name,
       page_id,
       page_name,
       region_name,
       region_id,
       parent_region_id,
       template_id,
       list_template_override_id,
       report_template_id,
       to_clob(region_source_sr1)  || to_clob(region_source_sr2)
       ||to_clob(region_source_sr3)|| to_clob(region_source_sr4) region_source_sr,
       U_NAME,
       U_VALUE,
       src_view_name
from
(
  select
         workspace,
         application_id,
         application_name,
         page_id,
         page_name,
         region_name,
         region_id,
         parent_region_id,
         template_id,
         list_template_override_id,
         report_template_id,
         region_source_sr1,
         region_source_sr2,
         region_source_sr3,
         region_source_sr4,
         U_NAME,
         U_VALUE,
         SRC_VIEW_NAME
  from pr
   UNPIVOT INCLUDE NULLS ( u_value
     FOR    u_name
     IN
     (   parent_region_name, template,
         static_id,
         rest_enabled,
         display_sequence,
         display_region_selector,
         region_attributes_substitution,
         display_column,
         display_position,
         display_position_code,
         region_source_hs,
         breadcrumb_template,
         list_template_override, source_type,
         on_error_message,
         authorization_scheme,
         condition_type,
         condition_expression1,
         condition_expression2,
         region_header_text,
         region_footer_text,
         report_template,
         report_column_headings,
         headings_type,
         maximum_rows_to_query,
         pagination_scheme,
         pagination_display_position,
         ajax_enabled,
         number_of_rows_item,
         no_data_found_message,
         more_data_found_message,
         maximum_row_count,
         report_null_values_as,
         breaks,
         ascending_image,
         ascending_image_attributes,
         descending_image,
         descending_image_attributes,
         filename,
         separator,
         enclosed_by,
         strip_html,
         report_column_source_type,
         max_dynamic_report_cols,
         html_table_cell_attributes,
         customization,
         customization_name,
         build_option,
         region_caching,
         timeout_cache_after,
         cache_when,
         cache_when_expression_1,
         cache_when_expression_2,
         sum_display_text,
         break_display_text,
         before_break_display_text,
         break_column_display_text,
         after_break_display_text,
         break_display_flag,
         repeat_heading_break_format,
         enable_csv_output,
         csv_link_label,
         url,
         link_label,
         translate_region_title,
         attribute_01,
         attribute_02,
         attribute_03,
         attribute_04,
         attribute_05,
         attribute_06,
         attribute_07,
         attribute_08,
         attribute_09,
         attribute_10,
         component_comment
     )
   )
) t;

